package com.blank.web.servlet;

import com.blank.web.bean.ClassBean;
import com.blank.web.service.ClassService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "showClassServlet",urlPatterns = "/showClassInfo")
public class showClassServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //1、查询所有班级的信息
        ClassService classService = new ClassService();
        List<ClassBean> list = classService.findAllClass();
        //2、将数据存储到request请求中
        request.setAttribute("list",list);
        System.out.println(list);
        //3、进行相应页面的跳转
        request.getRequestDispatcher("showClassInfo.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
